<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Command-module for Firefox &mdash; Dragonfly-modules v0.1 documentation</title>
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '0.1',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="top" title="Dragonfly-modules v0.1 documentation" href="index.html" />
    <link rel="next" title="Command-module for UltraEdit editor" href="mod-uedit32.html" />
    <link rel="prev" title="Command-module for sending keyboard breaks" href="mod-_kbbreak.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="mod-uedit32.html" title="Command-module for UltraEdit editor"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="mod-_kbbreak.html" title="Command-module for sending keyboard breaks"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">Dragonfly-modules v0.1 documentation</a> &raquo;</li> 
      </ul>
    </div>  
    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  
  <div class="section" id="command-module-for-firefox">
<h1>Command-module for <strong>Firefox</strong><a class="headerlink" href="#command-module-for-firefox" title="Permalink to this headline">¶</a></h1>
<p>This module offers direct control of the <a class="reference external" href="http://www.mozilla.com/en-US/firefox/">Firefox</a> web browser.  It
requires the <a class="reference external" href="https://addons.mozilla.org/en-US/firefox/addon/879">mouseless-browsing</a>
(mlb) add-on for reliable access to hyperlinks.</p>
<p>This module includes direct searching using Firefox&#8217;s
search bar and Firefox&#8217;s keyword searching.  It also
allows single-utterance submitting of text into form text
fields.</p>
<div class="section" id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline">¶</a></h2>
<p>If you are using DNS and Natlink, simply place this file in you Natlink
macros directory.  It will then be automatically loaded by Natlink when
you next toggle your microphone or restart Natlink.</p>
</div>
<div class="section" id="customization">
<h2>Customization<a class="headerlink" href="#customization" title="Permalink to this headline">¶</a></h2>
<p>Users should customize this module by editing its
configuration file.  In this file they should edit the
<tt class="docutils literal"><span class="pre">search.searchbar</span></tt> and <tt class="docutils literal"><span class="pre">search.keywords</span></tt> settings to
match their own personal search preferences.  These
variables map <em>what you say</em> to which <em>search engines</em> to
use.</p>
</div>
<div class="section" id="configuration-examples">
<h2>Configuration examples<a class="headerlink" href="#configuration-examples" title="Permalink to this headline">¶</a></h2>
<div class="section" id="configuration-firefox-en-txt">
<h3>Configuration &#8220;_firefox-en.txt&#8221;<a class="headerlink" href="#configuration-firefox-en-txt" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><table class="highlighttable"><tr><td class="linenos"><pre> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63</pre></td><td class="code"><div class="highlight"><pre><span class="c">#</span>
<span class="c"># Dragonfly config for Firefox control</span>
<span class="c">#</span>

<span class="c">#--- Search-related section ------------------------------------------------</span>

<span class="c"># Mapping of spoken-forms to Firefox search-keywords.</span>
<span class="n">search</span><span class="o">.</span><span class="n">keywords</span> <span class="o">=</span> <span class="p">{</span>
                   <span class="s">&#39;wikipedia&#39;</span><span class="p">:</span> <span class="s">&#39;wikipedia&#39;</span>
                  <span class="p">}</span>

<span class="c"># Spoken-forms of search engines in the Firefox</span>
<span class="c">#  search-bar; they must be given in the same</span>
<span class="c">#  order here as they are available in Firefox.</span>
<span class="n">search</span><span class="o">.</span><span class="n">searchbar</span> <span class="o">=</span> <span class="p">[</span>
                    <span class="s">&#39;google&#39;</span><span class="p">,</span> <span class="s">&#39;yahoo&#39;</span><span class="p">,</span> <span class="s">&#39;amazon&#39;</span><span class="p">,</span> <span class="s">&#39;answers&#39;</span><span class="p">,</span>
                    <span class="s">&#39;creative commons&#39;</span><span class="p">,</span> <span class="s">&#39;eBay&#39;</span><span class="p">,</span> <span class="s">&#39;wikipedia&#39;</span>
                   <span class="p">]</span>


<span class="c">#--- Language section ------------------------------------------------------</span>

<span class="n">lang</span><span class="o">.</span><span class="n">new_win</span>               <span class="o">=</span> <span class="s">&#39;new (window | win)&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">new_tab</span>               <span class="o">=</span> <span class="s">&#39;new (tab | sub)&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">close_tab</span>             <span class="o">=</span> <span class="s">&#39;close (tab | sub)&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">address_bar</span>           <span class="o">=</span> <span class="s">&#39;address [bar]&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">copy_address</span>          <span class="o">=</span> <span class="s">&#39;copy address&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">paste_address</span>         <span class="o">=</span> <span class="s">&#39;paste address&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">search_bar</span>            <span class="o">=</span> <span class="s">&#39;search bar&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">go_home</span>               <span class="o">=</span> <span class="s">&#39;go home&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">stop_loading</span>          <span class="o">=</span> <span class="s">&#39;stop loading&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">toggle_tags</span>           <span class="o">=</span> <span class="s">&#39;toggle tags&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">fresh_tags</span>            <span class="o">=</span> <span class="s">&#39;fresh tags&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">caret_browsing</span>        <span class="o">=</span> <span class="s">&#39;(caret | carrot) browsing&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">bookmark_page</span>         <span class="o">=</span> <span class="s">&#39;bookmark [this] page&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">save_page_as</span>          <span class="o">=</span> <span class="s">&#39;save [page | file] as&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">print_page</span>            <span class="o">=</span> <span class="s">&#39;print [page | file]&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">show_tab_n</span>            <span class="o">=</span> <span class="s">&#39;show tab &lt;n&gt;&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">back</span>                  <span class="o">=</span> <span class="s">&#39;back [&lt;n&gt;]&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">forward</span>               <span class="o">=</span> <span class="s">&#39;forward [&lt;n&gt;]&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">next_tab</span>              <span class="o">=</span> <span class="s">&#39;next tab [&lt;n&gt;]&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">prev_tab</span>              <span class="o">=</span> <span class="s">&#39;(previous | preev) tab [&lt;n&gt;]&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">normal_size</span>           <span class="o">=</span> <span class="s">&#39;normal text size&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">smaller_size</span>          <span class="o">=</span> <span class="s">&#39;smaller text size [&lt;n&gt;]&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">bigger_size</span>           <span class="o">=</span> <span class="s">&#39;bigger text size [&lt;n&gt;]&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">submit</span>                <span class="o">=</span> <span class="s">&#39;submit&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">submit_text</span>           <span class="o">=</span> <span class="s">&#39;submit &lt;text&gt;&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">find</span>                  <span class="o">=</span> <span class="s">&#39;find&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">find_text</span>             <span class="o">=</span> <span class="s">&#39;find &lt;text&gt;&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">find_next</span>             <span class="o">=</span> <span class="s">&#39;find next [&lt;n&gt;]&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">link_open</span>             <span class="o">=</span> <span class="s">&#39;[link] &lt;link&gt; [open]&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">link_select</span>           <span class="o">=</span> <span class="s">&#39;[link] &lt;link&gt; select&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">link_force</span>            <span class="o">=</span> <span class="s">&#39;[link] &lt;link&gt; force&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">link_window</span>           <span class="o">=</span> <span class="s">&#39;[link] &lt;link&gt; window&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">link_tab</span>              <span class="o">=</span> <span class="s">&#39;[link] &lt;link&gt; tab&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">link_copy</span>             <span class="o">=</span> <span class="s">&#39;[link] &lt;link&gt; copy&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">link_copy_into_tab</span>    <span class="o">=</span> <span class="s">&#39;[link] &lt;link&gt; copy into tab&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">link_list</span>             <span class="o">=</span> <span class="s">&#39;[link] &lt;link&gt; list&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">link_submit</span>           <span class="o">=</span> <span class="s">&#39;[link] &lt;link&gt; submit&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">link_submit_text</span>      <span class="o">=</span> <span class="s">&#39;[link] &lt;link&gt; submit &lt;text&gt;&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">search_text</span>           <span class="o">=</span> <span class="s">&#39;[power] search [for] &lt;text&gt;&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">search_keyword_text</span>   <span class="o">=</span> <span class="s">&#39;[power] search &lt;keyword&gt; [for] &lt;text&gt;&#39;</span>
<span class="n">lang</span><span class="o">.</span><span class="n">search_searchbar_text</span> <span class="o">=</span> <span class="s">&#39;[power] search &lt;searchbar&gt; [for] &lt;text&gt;&#39;</span>
</pre></div>
</td></tr></table></div>
</div>
</div>
<div class="section" id="module-source-code">
<h2>Module source code<a class="headerlink" href="#module-source-code" title="Permalink to this headline">¶</a></h2>
<p>The most current version of this module can be downloaded from the <a class="reference external" href="http://dragonfly-modules.googlecode.com/svn/trunk/command-modules/_firefox.py">repository here</a>.</p>
<div class="highlight-python"><table class="highlighttable"><tr><td class="linenos"><pre>  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286</pre></td><td class="code"><div class="highlight"><pre><span class="c">#</span>
<span class="c"># This file is a command-module for Dragonfly.</span>
<span class="c"># (c) Copyright 2008 by Christo Butcher</span>
<span class="c"># Licensed under the LGPL, see &lt;http://www.gnu.org/licenses/&gt;</span>
<span class="c">#</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Command-module for **Firefox**</span>
<span class="sd">============================================================================</span>

<span class="sd">This module offers direct control of the `Firefox</span>
<span class="sd">&lt;http://www.mozilla.com/en-US/firefox/&gt;`_ web browser.  It</span>
<span class="sd">requires the `mouseless-browsing</span>
<span class="sd">&lt;https://addons.mozilla.org/en-US/firefox/addon/879&gt;`_</span>
<span class="sd">(mlb) add-on for reliable access to hyperlinks.</span>

<span class="sd">This module includes direct searching using Firefox&#39;s</span>
<span class="sd">search bar and Firefox&#39;s keyword searching.  It also</span>
<span class="sd">allows single-utterance submitting of text into form text</span>
<span class="sd">fields.</span>

<span class="sd">Installation</span>
<span class="sd">----------------------------------------------------------------------------</span>

<span class="sd">If you are using DNS and Natlink, simply place this file in you Natlink</span>
<span class="sd">macros directory.  It will then be automatically loaded by Natlink when</span>
<span class="sd">you next toggle your microphone or restart Natlink.</span>

<span class="sd">Customization</span>
<span class="sd">----------------------------------------------------------------------------</span>

<span class="sd">Users should customize this module by editing its</span>
<span class="sd">configuration file.  In this file they should edit the</span>
<span class="sd">``search.searchbar`` and ``search.keywords`` settings to</span>
<span class="sd">match their own personal search preferences.  These</span>
<span class="sd">variables map *what you say* to which *search engines* to</span>
<span class="sd">use.</span>

<span class="sd">&quot;&quot;&quot;</span>

<span class="k">try</span><span class="p">:</span>
    <span class="kn">import</span> <span class="nn">pkg_resources</span>
    <span class="n">pkg_resources</span><span class="o">.</span><span class="n">require</span><span class="p">(</span><span class="s">&quot;dragonfly &gt;= 0.6.5beta1.dev-r76&quot;</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
    <span class="k">pass</span>

<span class="kn">from</span> <span class="nn">dragonfly</span> <span class="kn">import</span> <span class="p">(</span><span class="n">Grammar</span><span class="p">,</span> <span class="n">AppContext</span><span class="p">,</span> <span class="n">Rule</span><span class="p">,</span> <span class="n">MappingRule</span><span class="p">,</span> <span class="n">CompoundRule</span><span class="p">,</span>
                       <span class="n">Sequence</span><span class="p">,</span> <span class="n">Dictation</span><span class="p">,</span> <span class="n">Alternative</span><span class="p">,</span> <span class="n">Compound</span><span class="p">,</span>
                       <span class="n">Repetition</span><span class="p">,</span> <span class="n">Choice</span><span class="p">,</span> <span class="n">RuleRef</span><span class="p">,</span> <span class="n">IntegerRef</span><span class="p">,</span> <span class="n">Number</span><span class="p">,</span>
                       <span class="n">Key</span><span class="p">,</span> <span class="n">Text</span><span class="p">,</span> <span class="n">WaitWindow</span><span class="p">,</span> <span class="n">Pause</span><span class="p">,</span> <span class="n">Mouse</span><span class="p">,</span>
                       <span class="n">Config</span><span class="p">,</span> <span class="n">Section</span><span class="p">,</span> <span class="n">Item</span><span class="p">)</span>

<span class="c">#---------------------------------------------------------------------------</span>
<span class="c"># Set up this module&#39;s configuration.</span>

<span class="n">config</span>                 <span class="o">=</span> <span class="n">Config</span><span class="p">(</span><span class="s">&quot;Firefox control&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">search</span>          <span class="o">=</span> <span class="n">Section</span><span class="p">(</span><span class="s">&quot;Search-related section&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">search</span><span class="o">.</span><span class="n">keywords</span> <span class="o">=</span> <span class="n">Item</span><span class="p">(</span>
                              <span class="n">default</span><span class="o">=</span><span class="p">{</span>
                                       <span class="s">&quot;wikipedia&quot;</span><span class="p">:</span> <span class="s">&quot;wikipedia&quot;</span><span class="p">,</span>
                                      <span class="p">},</span>
                              <span class="n">doc</span><span class="o">=</span><span class="s">&quot;Mapping of spoken-forms to Firefox search-keywords.&quot;</span><span class="p">,</span>
                             <span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">search</span><span class="o">.</span><span class="n">searchbar</span> <span class="o">=</span> <span class="n">Item</span><span class="p">(</span>
                              <span class="n">default</span><span class="o">=</span><span class="p">[</span>
                                       <span class="s">&quot;google&quot;</span><span class="p">,</span>
                                       <span class="s">&quot;yahoo&quot;</span><span class="p">,</span>
                                       <span class="s">&quot;amazon&quot;</span><span class="p">,</span>
                                       <span class="s">&quot;answers&quot;</span><span class="p">,</span>
                                       <span class="s">&quot;creative commons&quot;</span><span class="p">,</span>
                                       <span class="s">&quot;eBay&quot;</span><span class="p">,</span>
                                       <span class="s">&quot;wikipedia&quot;</span><span class="p">,</span>
                                      <span class="p">],</span>
                              <span class="n">doc</span><span class="o">=</span><span class="s">&quot;Spoken-forms of search engines in the Firefox search-bar; they must be given in the same order here as they are available in Firefox.&quot;</span><span class="p">,</span>
                             <span class="p">)</span>

<span class="n">config</span><span class="o">.</span><span class="n">lang</span>                        <span class="o">=</span> <span class="n">Section</span><span class="p">(</span><span class="s">&quot;Language section&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">new_win</span>                <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;new (window | win)&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">new_tab</span>                <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;new (tab | sub)&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">close_tab</span>              <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;close (tab | sub)&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">close_tab_n</span>            <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;close (tab | sub) &lt;n&gt;&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">close_n_tabs</span>           <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;close &lt;n&gt; (tabs | subs)&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">address_bar</span>            <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;address [bar]&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">copy_address</span>           <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;copy address&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">paste_address</span>          <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;paste address&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">search_bar</span>             <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;search bar&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">go_home</span>                <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;go home&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">stop_loading</span>           <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;stop loading&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">toggle_tags</span>            <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;toggle tags&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">fresh_tags</span>             <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;fresh tags&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">caret_browsing</span>         <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;(caret | carrot) browsing&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">bookmark_page</span>          <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;bookmark [this] page&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">save_page_as</span>           <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;save [page | file] as&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">print_page</span>             <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;print [page | file]&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">show_tab_n</span>             <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;show tab &lt;n&gt;&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">back</span>                   <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;back [&lt;n&gt;]&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">forward</span>                <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;forward [&lt;n&gt;]&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">next_tab</span>               <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;next tab [&lt;n&gt;]&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">prev_tab</span>               <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;(previous | preev) tab [&lt;n&gt;]&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">normal_size</span>            <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;normal text size&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">smaller_size</span>           <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;smaller text size [&lt;n&gt;]&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">bigger_size</span>            <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;bigger text size [&lt;n&gt;]&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">find</span>                   <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;find&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">find_text</span>              <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;find &lt;text&gt;&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">find_next</span>              <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;find next [&lt;n&gt;]&quot;</span><span class="p">)</span>

<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">submit</span>                 <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;submit&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">submit_text</span>            <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;submit &lt;text&gt;&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">submit_clipboard</span>       <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;submit (clipboard | clip board)&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_open</span>              <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;[link] &lt;link&gt; [open]&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_save</span>              <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;save [link] &lt;link&gt; [as]&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_save_now</span>          <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;save [link] &lt;link&gt; now now&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_select</span>            <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;[link] &lt;link&gt; select&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_menu</span>              <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;[link] &lt;link&gt; (menu | pop up)&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_force</span>             <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;[link] &lt;link&gt; force&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_window</span>            <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;[link] &lt;link&gt; [in [new]] window&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_tab</span>               <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;[link] &lt;link&gt; [in [new]] tab&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_copy</span>              <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;[link] &lt;link&gt; copy&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_copy_into_tab</span>     <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;[link] &lt;link&gt; copy into tab&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_list</span>              <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;[link] &lt;link&gt; list&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_submit</span>            <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;[link] &lt;link&gt; submit&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_submit_text</span>       <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;[link] &lt;link&gt; submit &lt;text&gt;&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_submit_clipboard</span>  <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;[link] &lt;link&gt; submit (clipboard | clip board)&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_dictation_box</span>      <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;edit [link] &lt;link&gt;&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_assign_keyword</span>    <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;assign [a] keyword to [link] &lt;link&gt;&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">tabify_links</span>           <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;tab if I &lt;links&gt;&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">tabify_links_sep</span>       <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;comma&quot;</span><span class="p">)</span>

<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">search_text</span>            <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;[power] search [for] &lt;text&gt;&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">search_keyword_text</span>    <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;[power] search &lt;keyword&gt; [for] &lt;text&gt;&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">search_searchbar_text</span>  <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;[power] search &lt;searchbar&gt; [for] &lt;text&gt;&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">search_clipboard</span>       <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;[power] search [for] (clipboard | clip board)&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">search_keyword_clipboard</span> <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;[power] search &lt;keyword&gt; [for] clipboard&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">search_searchbar_clipboard</span> <span class="o">=</span> <span class="n">Item</span><span class="p">(</span><span class="s">&quot;[power] search &lt;searchbar&gt; [for] clipboard&quot;</span><span class="p">)</span>

<span class="c">#config.generate_config_file()</span>
<span class="n">config</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>


<span class="c">#---------------------------------------------------------------------------</span>
<span class="c"># Check and prepare search-related config values.</span>

<span class="n">keywords</span> <span class="o">=</span> <span class="n">config</span><span class="o">.</span><span class="n">search</span><span class="o">.</span><span class="n">keywords</span>
<span class="n">searchbar</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">([(</span><span class="n">n</span><span class="p">,</span><span class="n">i</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span><span class="p">,</span><span class="n">n</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">config</span><span class="o">.</span><span class="n">search</span><span class="o">.</span><span class="n">searchbar</span><span class="p">)])</span>


<span class="c">#---------------------------------------------------------------------------</span>
<span class="c"># Create the rule to match mouseless-browsing link numbers.</span>

<span class="k">class</span> <span class="nc">LinkRule</span><span class="p">(</span><span class="n">Rule</span><span class="p">):</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">element</span> <span class="o">=</span> <span class="n">Number</span><span class="p">(</span><span class="n">zero</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
        <span class="n">Rule</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s">&quot;link_rule&quot;</span><span class="p">,</span> <span class="n">element</span><span class="p">,</span> <span class="n">exported</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">value</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">node</span><span class="p">):</span>
        <span class="c"># Format and return keystrokes to select the link.</span>
        <span class="n">digits</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">children</span><span class="p">[</span><span class="mf">0</span><span class="p">]</span><span class="o">.</span><span class="n">value</span><span class="p">())</span>
        <span class="n">link_keys</span> <span class="o">=</span> <span class="s">&quot;f6,s-f6,&quot;</span> <span class="o">+</span> <span class="s">&quot;,&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="s">&quot;numpad&quot;</span><span class="o">+</span><span class="n">i</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">digits</span><span class="p">])</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_log</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&quot;Link keys: </span><span class="si">%r</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">link_keys</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">link_keys</span>

<span class="n">link</span> <span class="o">=</span> <span class="n">RuleRef</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&quot;link&quot;</span><span class="p">,</span> <span class="n">rule</span><span class="o">=</span><span class="n">LinkRule</span><span class="p">())</span>


<span class="c">#---------------------------------------------------------------------------</span>
<span class="c"># Create the main command rule.</span>

<span class="k">class</span> <span class="nc">CommandRule</span><span class="p">(</span><span class="n">MappingRule</span><span class="p">):</span>

    <span class="n">mapping</span> <span class="o">=</span> <span class="p">{</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">new_win</span><span class="p">:</span>            <span class="n">Key</span><span class="p">(</span><span class="s">&quot;c-n&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">new_tab</span><span class="p">:</span>            <span class="n">Key</span><span class="p">(</span><span class="s">&quot;c-t&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">close_tab</span><span class="p">:</span>          <span class="n">Key</span><span class="p">(</span><span class="s">&quot;c-w&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">close_tab_n</span><span class="p">:</span>        <span class="n">Key</span><span class="p">(</span><span class="s">&quot;0, </span><span class="si">%(n)d</span><span class="s">, enter/20, c-w&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">close_n_tabs</span><span class="p">:</span>       <span class="n">Key</span><span class="p">(</span><span class="s">&quot;c-w/20:</span><span class="si">%(n)d</span><span class="s">&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">address_bar</span><span class="p">:</span>        <span class="n">Key</span><span class="p">(</span><span class="s">&quot;a-d&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">copy_address</span><span class="p">:</span>       <span class="n">Key</span><span class="p">(</span><span class="s">&quot;a-d, c-c&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">paste_address</span><span class="p">:</span>      <span class="n">Key</span><span class="p">(</span><span class="s">&quot;a-d, c-v, enter&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">search_bar</span><span class="p">:</span>         <span class="n">Key</span><span class="p">(</span><span class="s">&quot;c-k&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">go_home</span><span class="p">:</span>            <span class="n">Key</span><span class="p">(</span><span class="s">&quot;a-home&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">stop_loading</span><span class="p">:</span>       <span class="n">Key</span><span class="p">(</span><span class="s">&quot;escape&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">toggle_tags</span><span class="p">:</span>        <span class="n">Key</span><span class="p">(</span><span class="s">&quot;f12&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">fresh_tags</span><span class="p">:</span>         <span class="n">Key</span><span class="p">(</span><span class="s">&quot;f12, f12&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">caret_browsing</span><span class="p">:</span>     <span class="n">Key</span><span class="p">(</span><span class="s">&quot;f7&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">bookmark_page</span><span class="p">:</span>      <span class="n">Key</span><span class="p">(</span><span class="s">&quot;c-d&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">save_page_as</span><span class="p">:</span>       <span class="n">Key</span><span class="p">(</span><span class="s">&quot;c-s&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">print_page</span><span class="p">:</span>         <span class="n">Key</span><span class="p">(</span><span class="s">&quot;c-p&quot;</span><span class="p">),</span>

        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">show_tab_n</span><span class="p">:</span>         <span class="n">Key</span><span class="p">(</span><span class="s">&quot;0, </span><span class="si">%(n)d</span><span class="s">, enter&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">back</span><span class="p">:</span>               <span class="n">Key</span><span class="p">(</span><span class="s">&quot;a-left/15:</span><span class="si">%(n)d</span><span class="s">&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">forward</span><span class="p">:</span>            <span class="n">Key</span><span class="p">(</span><span class="s">&quot;a-right/15:</span><span class="si">%(n)d</span><span class="s">&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">next_tab</span><span class="p">:</span>           <span class="n">Key</span><span class="p">(</span><span class="s">&quot;c-tab:</span><span class="si">%(n)d</span><span class="s">&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">prev_tab</span><span class="p">:</span>           <span class="n">Key</span><span class="p">(</span><span class="s">&quot;cs-tab:</span><span class="si">%(n)d</span><span class="s">&quot;</span><span class="p">),</span>

        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">normal_size</span><span class="p">:</span>        <span class="n">Key</span><span class="p">(</span><span class="s">&quot;a-v/20, z/20, r&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">smaller_size</span><span class="p">:</span>       <span class="n">Key</span><span class="p">(</span><span class="s">&quot;c-minus:</span><span class="si">%(n)d</span><span class="s">&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">bigger_size</span><span class="p">:</span>        <span class="n">Key</span><span class="p">(</span><span class="s">&quot;cs-equals:</span><span class="si">%(n)d</span><span class="s">&quot;</span><span class="p">),</span>

        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">submit</span><span class="p">:</span>             <span class="n">Key</span><span class="p">(</span><span class="s">&quot;enter&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">submit_text</span><span class="p">:</span>        <span class="n">Text</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(text)s</span><span class="s">&quot;</span><span class="p">)</span> <span class="o">+</span> <span class="n">Key</span><span class="p">(</span><span class="s">&quot;enter&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">submit_clipboard</span><span class="p">:</span>   <span class="n">Key</span><span class="p">(</span><span class="s">&quot;c-v, enter&quot;</span><span class="p">),</span>

        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">find</span><span class="p">:</span>               <span class="n">Key</span><span class="p">(</span><span class="s">&quot;c-f&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">find_text</span><span class="p">:</span>          <span class="n">Key</span><span class="p">(</span><span class="s">&quot;c-f&quot;</span><span class="p">)</span> <span class="o">+</span> <span class="n">Text</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(text)s</span><span class="s">&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">find_next</span><span class="p">:</span>          <span class="n">Key</span><span class="p">(</span><span class="s">&quot;f3/10:</span><span class="si">%(n)d</span><span class="s">&quot;</span><span class="p">),</span>

        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_open</span><span class="p">:</span>          <span class="n">Key</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(link)s</span><span class="s">, enter&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_save</span><span class="p">:</span>          <span class="n">Key</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(link)s</span><span class="s">, shift/10, apps/20, k&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_save_now</span><span class="p">:</span>      <span class="n">Key</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(link)s</span><span class="s">, shift/10, apps/20, k&quot;</span><span class="p">)</span>
                                         <span class="o">+</span> <span class="n">WaitWindow</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="s">&quot;Enter name of file&quot;</span><span class="p">)</span>
                                         <span class="o">+</span> <span class="n">Pause</span><span class="p">(</span><span class="s">&quot;20&quot;</span><span class="p">)</span> <span class="o">+</span> <span class="n">Key</span><span class="p">(</span><span class="s">&quot;enter&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_select</span><span class="p">:</span>        <span class="n">Key</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(link)s</span><span class="s">, shift&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_menu</span><span class="p">:</span>          <span class="n">Key</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(link)s</span><span class="s">, shift/10, apps&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_force</span><span class="p">:</span>         <span class="n">Key</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(link)s</span><span class="s">, shift/10, enter&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_window</span><span class="p">:</span>        <span class="n">Key</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(link)s</span><span class="s">, shift/10, apps/20, w&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_tab</span><span class="p">:</span>           <span class="n">Key</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(link)s</span><span class="s">, shift/10, apps/20, t&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_copy</span><span class="p">:</span>          <span class="n">Key</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(link)s</span><span class="s">, shift/10, apps/20, a&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_copy_into_tab</span><span class="p">:</span> <span class="n">Key</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(link)s</span><span class="s">, shift/10, apps/20, a/10, c-t/20, c-v, enter&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_list</span><span class="p">:</span>          <span class="n">Key</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(link)s</span><span class="s">, enter, a-down&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_submit</span><span class="p">:</span>        <span class="n">Key</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(link)s</span><span class="s">, enter/30, enter&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_submit_text</span><span class="p">:</span>   <span class="n">Key</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(link)s</span><span class="s">, enter/30&quot;</span><span class="p">)</span>
                                         <span class="o">+</span> <span class="n">Text</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(text)s</span><span class="s">&quot;</span><span class="p">)</span> <span class="o">+</span> <span class="n">Key</span><span class="p">(</span><span class="s">&quot;enter&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_submit_clipboard</span><span class="p">:</span> <span class="n">Key</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(link)s</span><span class="s">, enter/30, c-v, enter&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_dictation_box</span><span class="p">:</span> <span class="n">Key</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(link)s</span><span class="s">, enter/30, cs-d&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">link_assign_keyword</span><span class="p">:</span> <span class="n">Key</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(link)s</span><span class="s">, enter/10, apps/20, k&quot;</span><span class="p">),</span>

        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">search_text</span><span class="p">:</span>        <span class="n">Key</span><span class="p">(</span><span class="s">&quot;c-k&quot;</span><span class="p">)</span>
                                         <span class="o">+</span> <span class="n">Text</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(text)s</span><span class="s">&quot;</span><span class="p">)</span> <span class="o">+</span> <span class="n">Key</span><span class="p">(</span><span class="s">&quot;enter&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">search_searchbar_text</span><span class="p">:</span> <span class="n">Key</span><span class="p">(</span><span class="s">&quot;c-k, c-up:20, c-down:</span><span class="si">%(searchbar)d</span><span class="s">&quot;</span><span class="p">)</span>
                                         <span class="o">+</span> <span class="n">Text</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(text)s</span><span class="s">&quot;</span><span class="p">)</span> <span class="o">+</span> <span class="n">Key</span><span class="p">(</span><span class="s">&quot;enter&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">search_keyword_text</span><span class="p">:</span> <span class="n">Key</span><span class="p">(</span><span class="s">&quot;a-d&quot;</span><span class="p">)</span>
                                         <span class="o">+</span> <span class="n">Text</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(keyword)s</span><span class="s"> </span><span class="si">%(text)s</span><span class="s">&quot;</span><span class="p">)</span>
                                         <span class="o">+</span> <span class="n">Key</span><span class="p">(</span><span class="s">&quot;enter&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">search_clipboard</span><span class="p">:</span>   <span class="n">Key</span><span class="p">(</span><span class="s">&quot;c-k, c-v, enter&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">search_searchbar_clipboard</span><span class="p">:</span> <span class="n">Key</span><span class="p">(</span><span class="s">&quot;c-k, c-up:20, c-down:</span><span class="si">%(searchbar)d</span><span class="s">, c-v, enter&quot;</span><span class="p">),</span>
        <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">search_keyword_clipboard</span><span class="p">:</span> <span class="n">Key</span><span class="p">(</span><span class="s">&quot;a-d&quot;</span><span class="p">)</span> <span class="o">+</span> <span class="n">Text</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%(keyword)s</span><span class="s">&quot;</span><span class="p">)</span>
                                         <span class="o">+</span> <span class="n">Key</span><span class="p">(</span><span class="s">&quot;c-v, enter&quot;</span><span class="p">),</span>

        <span class="s">&quot;Feature freeze&quot;</span><span class="p">:</span> <span class="n">Mouse</span><span class="p">(</span><span class="s">&quot;(-15,0.6)/25, middle/25, &lt;0,15&gt;/100, &lt;0,5&gt;/100, &lt;0,5&gt;/100&quot;</span><span class="p">),</span>

        <span class="p">}</span>
    <span class="n">extras</span> <span class="o">=</span> <span class="p">[</span>
        <span class="n">link</span><span class="p">,</span>
        <span class="n">IntegerRef</span><span class="p">(</span><span class="s">&quot;n&quot;</span><span class="p">,</span> <span class="mf">1</span><span class="p">,</span> <span class="mf">20</span><span class="p">),</span>
        <span class="n">Dictation</span><span class="p">(</span><span class="s">&quot;text&quot;</span><span class="p">),</span>
        <span class="n">Choice</span><span class="p">(</span><span class="s">&quot;keyword&quot;</span><span class="p">,</span> <span class="n">keywords</span><span class="p">),</span>
        <span class="n">Choice</span><span class="p">(</span><span class="s">&quot;searchbar&quot;</span><span class="p">,</span> <span class="n">searchbar</span><span class="p">),</span>
        <span class="p">]</span>
    <span class="n">defaults</span> <span class="o">=</span> <span class="p">{</span>
        <span class="s">&quot;n&quot;</span><span class="p">:</span> <span class="mf">1</span><span class="p">,</span>
        <span class="p">}</span>


<span class="c">#---------------------------------------------------------------------------</span>
<span class="c"># Create the main command rule.</span>

<span class="k">class</span> <span class="nc">TabifyRule</span><span class="p">(</span><span class="n">CompoundRule</span><span class="p">):</span>

    <span class="n">spec</span> <span class="o">=</span> <span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">tabify_links</span>
    <span class="n">sep_element</span> <span class="o">=</span> <span class="n">Compound</span><span class="p">(</span><span class="n">config</span><span class="o">.</span><span class="n">lang</span><span class="o">.</span><span class="n">tabify_links_sep</span><span class="p">)</span>
    <span class="n">repeat_element</span> <span class="o">=</span> <span class="n">Sequence</span><span class="p">([</span><span class="n">sep_element</span><span class="p">,</span> <span class="n">link</span><span class="p">])</span>
    <span class="n">repetitions</span> <span class="o">=</span> <span class="n">Repetition</span><span class="p">(</span><span class="n">child</span><span class="o">=</span><span class="n">repeat_element</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mf">0</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">8</span><span class="p">)</span>
    <span class="n">extras</span> <span class="o">=</span> <span class="p">[</span><span class="n">Sequence</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">&quot;links&quot;</span><span class="p">,</span> <span class="n">children</span><span class="o">=</span><span class="p">(</span><span class="n">link</span><span class="p">,</span> <span class="n">repetitions</span><span class="p">))]</span>

    <span class="k">def</span> <span class="nf">_process_recognition</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">node</span><span class="p">,</span> <span class="n">extras</span><span class="p">):</span>
        <span class="n">link_nodes</span> <span class="o">=</span> <span class="n">node</span><span class="o">.</span><span class="n">get_children_by_name</span><span class="p">(</span><span class="s">&quot;link&quot;</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">link_nodes</span><span class="p">:</span>
            <span class="n">action</span> <span class="o">=</span> <span class="n">Key</span><span class="p">(</span><span class="n">n</span><span class="o">.</span><span class="n">value</span><span class="p">())</span> <span class="o">+</span> <span class="n">Key</span><span class="p">(</span><span class="s">&quot;shift/10, apps/20, t/20&quot;</span><span class="p">)</span>
            <span class="n">action</span><span class="o">.</span><span class="n">execute</span><span class="p">()</span>


<span class="c">#---------------------------------------------------------------------------</span>
<span class="c"># Create and load this module&#39;s grammar.</span>

<span class="n">context</span> <span class="o">=</span> <span class="n">AppContext</span><span class="p">(</span><span class="n">executable</span><span class="o">=</span><span class="s">&quot;firefox&quot;</span><span class="p">)</span>
<span class="n">grammar</span> <span class="o">=</span> <span class="n">Grammar</span><span class="p">(</span><span class="s">&quot;firefox_general&quot;</span><span class="p">,</span> <span class="n">context</span><span class="o">=</span><span class="n">context</span><span class="p">)</span>
<span class="n">grammar</span><span class="o">.</span><span class="n">add_rule</span><span class="p">(</span><span class="n">CommandRule</span><span class="p">())</span>
<span class="n">grammar</span><span class="o">.</span><span class="n">add_rule</span><span class="p">(</span><span class="n">TabifyRule</span><span class="p">())</span>
<span class="n">grammar</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>

<span class="c"># Unload function which will be called by natlink at unload time.</span>
<span class="k">def</span> <span class="nf">unload</span><span class="p">():</span>
    <span class="k">global</span> <span class="n">grammar</span>
    <span class="k">if</span> <span class="n">grammar</span><span class="p">:</span> <span class="n">grammar</span><span class="o">.</span><span class="n">unload</span><span class="p">()</span>
    <span class="n">grammar</span> <span class="o">=</span> <span class="bp">None</span>
</pre></div>
</td></tr></table></div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3><a href="index.html">Table Of Contents</a></h3>
            <ul>
<li><a class="reference external" href="">Command-module for <strong>Firefox</strong></a><ul>
<li><a class="reference external" href="#installation">Installation</a></li>
<li><a class="reference external" href="#customization">Customization</a></li>
<li><a class="reference external" href="#configuration-examples">Configuration examples</a><ul>
<li><a class="reference external" href="#configuration-firefox-en-txt">Configuration &#8220;_firefox-en.txt&#8221;</a></li>
</ul>
</li>
<li><a class="reference external" href="#module-source-code">Module source code</a></li>
</ul>
</li>
</ul>

            <h4>Previous topic</h4>
            <p class="topless"><a href="mod-_kbbreak.html" title="previous chapter">Command-module for sending <strong>keyboard breaks</strong></a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="mod-uedit32.html" title="next chapter">Command-module for <strong>UltraEdit</strong> editor</a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="_sources/mod-_firefox.txt">Show Source</a></li>
            </ul>
          <h3>Quick search</h3>
            <form class="search" action="search.html" method="get">
              <input type="text" name="q" size="18" /> <input type="submit" value="Go" />
              <input type="hidden" name="check_keywords" value="yes" />
              <input type="hidden" name="area" value="default" />
            </form>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="mod-uedit32.html" title="Command-module for UltraEdit editor"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="mod-_kbbreak.html" title="Command-module for sending keyboard breaks"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">Dragonfly-modules v0.1 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright 2008, Christo Butcher.
      Last updated on Apr 10, 2009.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.1.
    </div>
  </body>
</html>